#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QtGui>
#include <QtNetwork>
#include <QtCore>
#include "./../sota/sota.h"

namespace Ui {
    class MainWindow;
}

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    explicit MainWindow(QWidget *parent = 0);
    ~MainWindow();

private:
    Ui::MainWindow *ui;
	QString cur_address;
	bool eventFilter(QObject * _object, QEvent * _event);
	void parseFiles(const QList<QUrl> & _urls);
	static QString currentTime() { return QTime::currentTime().toString("hh:mm:ss.zzz"); }
	static QString currentIp() { return QNetworkInterface::allAddresses().at(0).toString(); }
	static QString sizeMb(int _size_in_bytes) { return QString::number(_size_in_bytes / (1024.0 * 1024.0), '.', 2); }
	void printToLog(
			bool _local,
			const QString & _text,
			const QString & _time = currentTime(),
			const QString & _ip = currentIp());
	void reconnect();
	void changeIp(const QString & _ip);
signals:
	void message(QString _text, QString _time, QString _ip);
	void file(QString _name, int _size, QByteArray _md5, QString _time, QString _ip, QByteArray _data);

private slots:
	void on_send_clicked();
	void on_actionExit_triggered();
	void on_message(QString _text, QString _time, QString _ip);
	void on_file(QString _name, int _size, QByteArray _md5, QString _time, QString _ip, QByteArray _data);
};

#endif // MAINWINDOW_H
